<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk">

<f:view>
<f:loadBundle var="messages" basename="messages"/>

<head>
	<c:if test="${not empty topicoForm.id}">
<h1>Editar Topico</h1>
	</c:if>
	
	<c:if test="${empty topicoForm.id}">
<h1>Novo Topico</h1>
	</c:if>
	
    <style type="text/css">
        .jscalendar-DB-div-style {
            position: absolute;
            margin-top: -69px;
            margin-left: -408px;
        }
    </style>
</head>

<h:messages errorClass="error" layout="table" style="width: 100%"/>
  

 
<h:form id="topicoForm">
<h:inputHidden value="#{topicoForm.topico.id}">
    <f:convertNumber/>
</h:inputHidden>
<h:panelGrid columns="3" styleClass="detail" columnClasses="label">

	<h:outputLabel value="Comunidade" for="comunidadeNome" />
	<br />
	<br />
	<h:selectOneListbox id="nomeComunidade" required="true" size="1"
	requiredMessage="Informe a Comunidade do Topico!"
	value="#{topicoForm.comunidadeId}">
	<f:selectItems value="#{topicoForm.listaDeComunidades}" />
	</h:selectOneListbox>

    <h:outputLabel for="Assunto" value="#{messages['topico.titulo']}"/>
    <br />
    <br />
    <h:inputText value="#{topicoForm.topico.titulo}" 
    id="titulo" 
    required="true" requiredMessage="O assunto deve ser informado!">
    <h:message for="titulo" styleClass="errorMessage"/>
    <f:validateLength maximum="30" />
    </h:inputText>
    

    <h:outputLabel for="Mensagem" value="#{messages['topico.descricao']}"/>
    <br />
    <br />    
    <h:inputTextarea value="#{topicoForm.topico.descricao}" 
    id="descricao" 
    required="true" requiredMessage="A mensagem deve ser informada!"
    cols="300" rows="300" style="overflow:scroll">
	<f:validateLength maximum="1000" />
	</h:inputTextarea>			
    <h:message for="descricao" styleClass="errorMessage"/>
 
    <h:panelGroup>
        <h:commandButton value="Enviar" action="#{topicoForm.save}" id="save" styleClass="button"/>
    <c:if test="${not empty topicoForm.id}">
        <h:commandButton value="Deletar" action="#{topicoForm.delete}" id="delete" styleClass="button"/>
    </c:if>
        <h:commandButton value="Cancelar" action="cancel" immediate="true" id="cancel" styleClass="button"/>
    </h:panelGroup>
</h:panelGrid>
</h:form>

<script type="text/javascript">
    Form.focusFirstElement(document.forms['topicoForm']);
</script>

</f:view>
</html>